package com.itany.corejava.code09_异常;

/**
 * @author MissChen
 * @date 2024年03月07日 14:52
 */
public class Test07_debug调试 {
    public static void main(String[] args) {
        UserService userService=new UserService();
        try {
            userService.register("bb","123");
        } catch (UserExistException e) {
            System.out.println(e.getMessage());
        }
    }
}

class UserDao{
    public void insertUser(String username,String password) throws UserExistException {
        if("admin".equals(username)){
            throw new UserExistException("该用户已经被注册了");
        }
        System.out.println("注册成功");
    }
}
class UserService{
    UserDao userDao=new UserDao();
    public void register(String username,String password) throws UserExistException {
        for(int i=0;i<5;i++){
            System.out.println(i);
            int j=i+2;
            j=i/j;
        }
        userDao.insertUser(username,password);
    }
}